
$(document).ready(function() {

if ($("#scroller").length){    
// initialize scrollable together with the autoscroll plugin
var root = $("#scroller").scrollable({circular: false}).autoscroll({ autoplay: true });

// provide scrollable API for the action buttons
window.api = root.data("scrollable");

//activate buttons
$('#playBut').click(function(){
    api.play();
});
$('#pauseBut').click(function(){
    api.pause();
});
$('#stopBut').click(function(){
    api.stop();
});

}
    
$('#cDelete').click(function(){
    var confirmMsg = "Are you sure you want to delete this Comment?\nClick Ok to Delete.";
    if (confirm(confirmMsg)) {                                                                                      
        $('#cAct').val('delete');
        $('#commentForm').submit(); 
       }  
}
);

$('#rDelete').click(function(){
                
    var confirmMsg = "Are you sure you want to delete this Report?\nClick Ok to Delete.";
    if (confirm(confirmMsg)) {
        $('#repAct').val('delete');
        $('#reportForm').submit();
       }           
}
);

$('#scnDelete').click(function(){
                
    var confirmMsg = "Are you sure you want to delete this Scenario?\nClick Ok to Delete.";
    if (confirm(confirmMsg)) {
        $('#scnAct').val('delete');
        $('#scnForm').submit();
       }           
}
);
$('#busDelete').click(function(){
                
    var confirmMsg = "Are you sure you want to delete this Business?\nClick Ok to Delete.";
    if (confirm(confirmMsg)) {
        $('#busAct').val('delete');
        $('#busForm').submit();
       }           
}
);

$('#scnSubmit').click(function(){
  //  alert($('input.scnRep:checked').length);
    
    if ($('input.scnRepChk:checked').length>0){
        var reports   = [];                       
            $('input.scnRepChk:checked').each(function(){
                             reports.push($(this).val());
                                     
                                 })
        
     $('#scnReports').val(reports.toString())   ;
     
 //    alert($('#scnReports').val()); 
    }
    // submit form
    $('#scnForm').submit();  
    
}
);

$('#busSubmit').click(function(){
  //  alert($('input.scnRep:checked').length);
    
    if ($('input.busScnChk:checked').length>0){
        var scenarios   = [];                       
            $('input.busScnChk:checked').each(function(){
                             scenarios.push($(this).val());
                                     
                                 })
        
     $('#busScenarios').val(scenarios.toString())   ;
     
 //    alert($('#scnReports').val()); 
    }
    // submit form
    $('#busForm').submit();  
    
}
);


$('img.repImg').click(function(){
  //  alert($('input.scnRep:checked').length);
   imgSrc= $(this).attr('src');
   if (imgSrc !== '') {
       openImage(imgSrc);
       return false;
   }
}
);

});


function openImage(myUrl) {       
    newWin = window.open(myUrl, 'myconsole', 'width=650,height=550' + ',menubar=0' + ',toolbar=1' + ',status=1' + ',scrollbars=yes' + ',resizable=1');
    newWin.focus();
    return false;

}